package torres.utility;

import java.util.Random;

public class Statistics {
	
	private static Random random = new Random();
	
	public static boolean attempt(int yourStat, int enemyStat) {
		boolean ret = false;
		double hitRate = -1 * ((double)enemyStat/yourStat);
		int threshold = (int)(100*Math.exp(hitRate));
		if(random.nextInt(101) > threshold)
			ret = true;
		
		return ret;
	}
	
	public static int normalDist(int expected) {
		
		expected = 5;
		return Math.abs((int)(expected*random.nextGaussian()) + expected);
	}
	
	public static boolean passFail(int highestMissRate, int skillLevel, int skillLevelImprovement){
		
		boolean pass = false;
		
		int passRate = random.nextInt(100) + 1;
		int failRate = highestMissRate - ((skillLevel - 1) * skillLevelImprovement);
		if(passRate > failRate)
			pass = true;
		
		return pass;
	}
	
	public static boolean passFail(int skillLevel){
		
		boolean pass = false;
		
		int passRate = random.nextInt(100) + 1;
		int failRate = 40 - ((skillLevel - 1) * 4);
		if(passRate > failRate)
			pass = true;
		
		return pass;
	}
}
